package com.xiyu.service.controller.admin.nurse;
import com.xiyu.service.vo.nurse.nursePlan.NursePlanPageOutput;
import com.xiyu.service.vo.nurse.nursePlan.NursePlanPageInput;
import com.xiyu.service.vo.nurse.nursePlan.NursePlanGetOutput;
import com.xiyu.service.vo.nurse.nursePlan.NursePlanUpdateInput;
import com.xiyu.service.vo.nurse.nursePlan.NursePlanCreateInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.nurse.NursePlanService;

@Tag(name = "护理计划")
@RestController
@RequestMapping("/nurse/nurse-plan")
@Validated
public class NursePlanController {

    @Resource
    private NursePlanService nursePlanService;

    @PostMapping("/create")
    @Operation(summary = "创建护理计划")
    @PreAuthorize("@ss.hasPermission('nurse:plan:create')")
    public CommonResult<Long> create(@Valid @RequestBody NursePlanCreateInput inputVO) {
        return success(nursePlanService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新护理计划")
    @PreAuthorize("@ss.hasPermission('nurse:plan:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody NursePlanUpdateInput inputVO) {
        return success(nursePlanService.update(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个护理计划")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<NursePlanGetOutput> get(@RequestParam("id") Long id) {
        return success(nursePlanService.get(id));
    }

    @GetMapping("/page")
    @Operation(summary = "分页查询护理计划")
    @PreAuthorize("@ss.hasPermission('nurse:plan:query')")
    public CommonResult<PageResult<NursePlanPageOutput>> page(@Valid NursePlanPageInput inputVO) {
        return success(nursePlanService.page(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除护理计划")
    @PreAuthorize("@ss.hasPermission('nurse:plan:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(nursePlanService.deleted(id));
    }

}
